package cn.harry.modular.monitor.service.impl;

import cn.harry.modular.monitor.mapper.SysOperationLogMapper;
import cn.harry.modular.monitor.domain.SysOperationLog;
import cn.harry.modular.monitor.service.SysOperationLogService;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName: SysOperationLogServiceImpl Description:
 *
 * @author honghh Date 2020/04/20 16:02 Copyright (C) www.tech-harry.cn
 */
@Service
public class SysOperationLogServiceImpl
		extends ServiceImpl<SysOperationLogMapper, SysOperationLog>
		implements SysOperationLogService {

	@Override
	public void clean() {
		this.baseMapper.clean();
	}

	@Override
	public List<SysOperationLog> getExportList(SysOperationLog sysOperationLog) {
		LambdaQueryWrapper<SysOperationLog> wrapper = Wrappers
				.<SysOperationLog>lambdaQuery()
				.gt(StrUtil.isNotEmpty(sysOperationLog.getBeginTime()),
						SysOperationLog::getCreateTime, sysOperationLog.getBeginTime())
				.lt(StrUtil.isNotEmpty(sysOperationLog.getEndTime()),
						SysOperationLog::getCreateTime, sysOperationLog.getEndTime());
		return list(wrapper);
	}

}
